# -*- coding:utf-8 -*-
# @Time: 2020-08-29 17:51
# @Author: aniu
# @File: application.py
from flask import Flask
from flask_cors import CORS
from flask_script import Manager
from flask_sqlalchemy import SQLAlchemy
import os


'''
    template_folder 指定模板存放路径，
    static_folder 指定静态文件的存放路径
    static_url_path 指定静态文件访问路径
'''

class Application(Flask):
    def __init__(self, import_name, template_folder = None, static_folder = None, root_path = None):
        super(Application, self).__init__(import_name, template_folder=template_folder, static_folder=static_folder, root_path=root_path)
        self.config.from_pyfile('config/setting.py')

        db.init_app(self)

    def add_url_rule(self, rule, endpoint=None, view_func=None, **options):
        if endpoint is None:
            endpoint = rule

        super(Application, self).add_url_rule(rule, endpoint=endpoint, view_func=view_func,  **options )



db = SQLAlchemy()

# folder = "./web/view"
# static_folder="./layui"
app = Application(__name__,template_folder='', static_folder='', root_path=os.getcwd())
# 跨域问题解决。
CORS(app, supports_credentials=True)
manager = Manager(app)
